<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>垂直居中</title>
    <style>
        div {
            position: relative;
            width: 300px;
            height: 300px;
            background-color: aquamarine;
            /* text-align: center;
            line-height: 300px; */
        }

        div a {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
        }

        span {
            display: inline-block;
            width: 300px;
            height: 300px;
            background-color: yellow;
            text-align: center;

        }
    </style>
</head>
<body>
    <div>
        <a href="#">百度一下</a>
    </div>

    <span>
        <a href="#">京东</a>
    </span>
</body>
</html>